package com.dao;

import com.entity.IdCard;
import org.apache.ibatis.annotations.*;

public interface IdCardMapper {

    @Select("select * from idcard where id=#{id}")
    public IdCard getIdCardById(Integer id);

    @Insert("insert into idcard (code) values (#{code})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    int addIdCard(IdCard card);

    //使用内连接方法
    @Select("select s.*,c.id,c.code from students s,idcard c where s.cid = c.id and c.id=#{id}")
    @Results({@Result(property = "stu.sid",column = "sid" ),
            @Result(property = "stu.sname",column = "sname"),
            @Result(property = "stu.gender",column = "gender"),
            @Result(property = "stu.birthday",column = "birthday"),
            @Result(property = "stu.major",column = "major")
    })
    public IdCard getIdCardWithStudentById(Integer id);
}
